﻿// DigitalDesign
// Project: InformationBoard
// Developer: Baevskih Aleksandr
// Created: 16.11.2011
// Last change: 16.11.2011

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.ServiceModel;

namespace Server
{
    [DataContract]
    public class VideoWarp
    {
        DataModelContainer DateBase = new DataModelContainer();

        public VideoWarp() { }

        void Init()
        {
            FileName = new List<string>();
            VideoID = new List<int>();
            Description = new List<string>();
        }

        public bool CreateWarp()
        {
            Init();

            foreach (Video tempVideo in DateBase.Videos)
            {
                FileName.Add(tempVideo.FileName);
                VideoID.Add(tempVideo.Id);
                Description.Add(tempVideo.Description);
            }

            if (FileName.Count == 0)
                return false;

            return true;
        }

        public bool CreateWarp(int ClientID)
        {
            Init();

            foreach (Video tempVideo in DateBase.Videos)
            {
                if ((from _playlists in DateBase.Playlists
                     where _playlists.ClientDevice_Id == ClientID && _playlists.Video_Id == tempVideo.Id
                     select _playlists).Count() == 0)
                    continue;

                FileName.Add(tempVideo.FileName);
                VideoID.Add(tempVideo.Id);
                Description.Add(tempVideo.Description);
            }

            if (FileName.Count == 0) 
                return false;

            return true;
        }

        [DataMember]
        public List<string> FileName
        {
            get;
            set;
        }

        [DataMember]
        public List<int> VideoID
        {
            get;
            set;
        }

        [DataMember]
        public List<string> Description
        {
            get;
            set;
        }
    }
}
